﻿using MetaProperties.Core;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace MetaProperties.Core.Tests
{
    using System;


    /// <summary>
    ///This is a test class for ReadOnlyObservableTest and is intended
    ///to contain all ReadOnlyObservableTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ReadOnlyObservableTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Value
        ///</summary>
        public void DefaultValueTestHelper<T>()
        {
            ReadOnlyObservable<T> target = new ReadOnlyObservable<T>();
            T expected = Activator.CreateInstance<T>();
            T actual;
            actual = target.Value;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void DefaultValueTest()
        {
            DefaultValueTestHelper<int>();
        }

        /// <summary>
        ///A test for Value
        ///</summary>
        public void ValueTestHelper<T>(T defaultValue)
        {
            ReadOnlyObservable<T> target = new ReadOnlyObservable<T>(defaultValue);
            T expected = defaultValue;
            T actual;
            actual = target.Value;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void ValueTest()
        {
            ValueTestHelper<GenericParameterHelper>(new GenericParameterHelper(5));
        }

        /// <summary>
        ///A test for GetValue
        ///</summary>
        public void GetValueTestHelper<T>(T defaultValue)
        {
            ReadOnlyObservable<T> container = new ReadOnlyObservable<T>(defaultValue);
            PrivateObject param0 = new PrivateObject(container);
            ReadOnlyObservable_Accessor<T> target = new ReadOnlyObservable_Accessor<T>(param0);
            object expected = defaultValue;
            object actual;
            actual = target.GetValue();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("MetaProperties.Core.dll")]
        public void GetValueTest()
        {
            GetValueTestHelper<GenericParameterHelper>(new GenericParameterHelper(7));
        }

        /// <summary>
        ///A test for ReadOnlyObservable`1 Constructor
        ///</summary>
        public void ReadOnlyObservableConstructorTest1Helper<T>()
        {
            ReadOnlyObservable<T> target = new ReadOnlyObservable<T>();
            Assert.IsNotNull(target.Value);
            Assert.IsInstanceOfType(target.Value, typeof(T));
        }

        [TestMethod()]
        public void ReadOnlyObservableConstructorTest1()
        {
            ReadOnlyObservableConstructorTest1Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///A test for ReadOnlyObservable`1 Constructor
        ///</summary>
        public void ReadOnlyObservableConstructorTestHelper<T>(T defaultValue)
        {
            ReadOnlyObservable<T> target = new ReadOnlyObservable<T>(defaultValue);
            Assert.AreEqual(defaultValue, target.Value);
        }

        [TestMethod()]
        public void ReadOnlyObservableConstructorTest()
        {
            ReadOnlyObservableConstructorTestHelper<GenericParameterHelper>(new GenericParameterHelper(6));
        }
    }
}
